<template>
  <view>
    <view v-if="!item.ad_id">
      <view style="margin-top:20rpx;"></view>
      <uni-card :title="item.user.nick_name" :isFull="!isRedirect" :sub-title="item.create_at"   :thumbnail="item.user.avatar" @click="x_redirect('/pages/wall/wall_detail?id='+item.id)">
        <text class="uni-body uni-mt-5" style="margin-bottom:10px;word-break: break-all;">
          {{item.content}}
        </text>
        <uni-file-picker readonly :value="item.pics"  file-mediatype="image"></uni-file-picker>
        <view v-if="isRedirect" slot="actions" class="card-actions">
          <view class="card-actions-item" @click="actionsClick('分享')">
            <uni-icons type="redo" size="18" color="#999"></uni-icons>
            <text class="card-actions-item-text">分享（{{item.share_num}}）</text>
          </view>
          <view class="card-actions-item" @click.stop="actionsClick('like')">
            <uni-icons v-if="xitem.is_like" type="hand-up" size="18" color="#007aff"></uni-icons>
            <uni-icons v-else type="hand-up" size="18" color="#666"></uni-icons>
            <text v-if="xitem.is_like" class="card-actions-item-text" style="color:#007aff" >点赞（{{xitem.like_num}}）</text>
            <text v-else class="card-actions-item-text" style="color:#666">点赞（{{xitem.like_num}}）</text>
          </view>
          <view class="card-actions-item" @click="actionsClick('评论')">
            <uni-icons type="chatbubble" size="18" color="#999"></uni-icons>
            <text class="card-actions-item-text">评论（{{item.comment_num}}）</text>
          </view>
        </view>
      </uni-card>
    </view>
    <ad :unit-id="item.ad_id" v-if="item.from === 'wx'" ></ad>
    <ad :adpid="item.ad_id" v-if="item.from === 'uni'"></ad>
  </view>
</template>
<script>
import x from '@/common/base.js';
export default {
  name: "wall",
  data() {
    return {
        xitem:{}
    }
  },
  mounted: function () {
    this.xitem = this.item;
  },
  methods: {
    toDeail(){
      if(this.isRedirect ===1){
        uni.navigateTo({
          url: '/pages/wall/wall_detail?id='+this.item.id
        });
      }
      return false;
    },
    actionsClick(event){
      if(event === 'like'){
        x.wallLike(this,this.item.id,1);
      }
    }
  },
  props: ["item","isRedirect"],
};
</script>
<style lang="scss">


.card-actions {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  height: 45px;
  border-top: 1px #eee solid;
}

.card-actions-item {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.card-actions-item-text {
  font-size: 12px;
  color: #666;
  margin-left: 5px;
}

.cover-image {
  flex: 1;
  height: 150px;
}

.no-border {
  border-width: 0;
}

.x_gird_image {
  width: 100%;
  height: 100%;
  display: inline-block;
  overflow: hidden;
}

.text {
  font-size: 14px;
  margin-top: 5px;
}

.example-body {
  /* #ifndef APP-NVUE */
  // display: block;
  /* #endif */
}

.grid-dynamic-box {
  margin-bottom: 15px;
}

.grid-item-box {
  flex: 1;
  // position: relative;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 0;
}

.grid-item-box-row {
  flex: 1;
  // position: relative;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 15px 0;
}

.grid-dot {
  position: absolute;
  top: 5px;
  right: 15px;
}

.swiper {
  height: 420px;
}

/* #ifdef H5 */
@media screen and (min-width: 768px) and (max-width: 1425px) {
  .swiper {
    height: 630px;
  }
}

@media screen and (min-width: 1425px) {
  .swiper {
    height: 830px;
  }
}
.uni-card .uni-card__header {border-bottom: 0px solid #FFFFFF !important;}
.uni-card__header{border-top:0px;}

/* #endif */

</style>
